import { CHANGE_BANNER_LIST, CHANGE_PRO_LIST } from '../types'

// 一个状态模块就是一个 reducer，reducer中有定义全局状态，也有修改状态的方法
const reducer = (state = {
  // 全局状态
  bannerList: [],
  proList: []
}, action) => {

  switch (action.type) {
    case CHANGE_BANNER_LIST:
      return { ...state, bannerList: action.payload }

    case CHANGE_PRO_LIST:
      return { ...state, proList: action.payload }

    default:
      return state
  }
}

export default reducer
